import service from '../utils/request'

/**
 * （不建议写成 request.post(xxx)，因为这样 post 时，无法 params 与 data 同时传参）
 *
 * 登录api接口集合
 * @method signIn 用户登录
 * @method signOut 用户退出登录
 */
// 用户注册
export function useLoginApi(data: object | null | undefined) {
  return service({
    url: '/oauth-service/v1/sys-user/logon',
    method: 'post',
    data,
  })
}
// 短信验证
export function sendNote(data: { messageType: string; phone: string }) {
  return service({
    url:
      '/xinfa-service/v1/message/send?messageType=' +
      data.messageType +
      '&phone=' +
      data.phone,
    method: 'post',
  })
}
// 账号密码登录
export function loginAccount(data: object | null | undefined) {
  return service({
    url: '/oauth-service/v1/user/login/account',
    method: 'post',
    data,
  })
}
// 微信扫码登录
export function loginweChat(data: { linkSystem: string; openId: string }) {
  return service({
    url:
      '/oauth-service/v1/user/login/weChat?linkSystem=' +
      data.linkSystem +
      '&openId=' +
      data.openId,
    method: 'post',
    data,
  })
}
// 手机验证码登录
export function loginPhone(data: any) {
  return service({
    url: '/oauth-service/v1/user/login/phone',
    method: 'post',
    data,
  })
}
// 忘记密码
export function forgotPassword(data: any) {
  return service({
    url: '/oauth-service/v1/user/forgotPassword',
    method: 'post',
    data,
  })
}
